package com.example.dishit.service.recommendation;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import com.example.dishit.model.dish.DishData;

public class FakeRecommendationGenerator implements IRecommendationGenerator {
    private static final String THIS_GENERATOR_ID = "Recommendation Service";
    
    private final Executor thread = Executors.newSingleThreadExecutor();
    
    public void requestRecommendation(final IRecommendationListener callback) {
        thread.execute(new Runnable() {
            public void run() {
                callback.onRecommendation(generateRecommendation());
            }
        });
    }
    
    public static DishData generateRecommendation() {
        // Simulate processing delay (i.e. sleep for 5 seconds).
        //try { Thread.sleep(5000); }
        //catch (InterruptedException e) { e.printStackTrace(); }
        
        final List<String> imageUrls = new ArrayList<String>();
        imageUrls.add("http://s3-media3.ak.yelpcdn.com/bphoto/PvAmUf4TV9EX__z2sjwZnQ/l.jpg");
        
        final List<String> comments = new ArrayList<String>();
        comments.add("Alice:    what a dump.");
        comments.add("Betty:    We had a great time.  Came early stayed there for a while.  Four score and seven years ago our forefathers brought on this contient a nation conceived in liberty and decidated to the proposition that all men are created equal.");
        comments.add("Carl:    Look at what I say oh.  The more I see the less I know that more I like to let it go.  Hey oh, woah oh oh.  Deep beneah the cover of another perfect wonder where it's all white as snow.  Narrowly divided by a world so undecided and there's no where to go.  In between the cover of another perfect wonder.");
        
        // Return fake recommendation.
        return new DishData.Builder()
                    .recommendedBy(THIS_GENERATOR_ID)
                    .restaurantName("Cutters Crabhouse")
                    .priceMin(23.15f)
                    .priceMax(40.02f)
                    .imageUrls(imageUrls)
                    .keywords(Arrays.asList("seafood", "expensive", "seattle", "waterview", "downtown", "hang out", "Seattle", "happy hour"))
                    .reasons(Arrays.asList("like seafood", "highly rated", "friends recommended it", "great appetizers", "local cuisine", "like beer"))
                    .rating(2.4f)
                    .comments(comments)
                    .websiteUrl("http://www.cutterscrabhouse.com")
                    .mapUrl("https://maps.google.com/maps?client=ubuntu&channel=fs&q=seattle+to+cutters+crabhouse&oe=utf-8&um=1&ie=UTF-8&hl=en&sa=N&tab=wl")
                    .streetAddress("123 Fake Street")
                    .city("Seattle")
                    .state("WA")
                    .zipcode("12345-6789")
                    .phoneNumberDigits("5555555555")
                    .build();
    }
}
